package com.hns.can.report.web;

import com.hns.can.common.web.BaseController;
import com.hns.can.report.entity.TBsTyCleanSecEntity;
import com.hns.can.report.service.CarDataAnaService;
import com.hns.can.report.vo.CarDataAnaVo;
import com.hns.tool.pub.PubUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * The type Car data ana controller.
 * 行车数据分析-控制类
 *
 * @author # xujf（835264047@qq.com）
 * @date # 2016-12-22 17:30:47
 */
@Controller
@RequestMapping("/carDataAna")
public class CarDataAnaController extends BaseController {

    @Autowired
    private CarDataAnaService carDataAnaService;


    // DOIT: 2016-12-19 获取行车记录分析数据

    /**
     * Gets car recode ana data.
     * 获取行车记录分析数据
     *
     * @param vo the vo
     * @return the car recode ana data
     * @throws Exception the exception
     * @author # xujf（835264047@qq.com）
     * @date # 2016-12-22 17:32:15
     */
    @RequestMapping("/getCarRecodeAnaData")
    @ResponseBody
    public Object getCarRecodeAnaData(CarDataAnaVo vo) throws Exception {

        // 1、获取ty文件的1/s数据
        List<TBsTyCleanSecEntity> list = carDataAnaService.getCarRecodeAnaDataItvalSec(vo);

        if (PubUtil.isEmpty(list)) {
            // 2、获取定时的1/m数据
            list = carDataAnaService.getCarRecodeAnaDataItvalMin(vo);
        }

        return this.getReturnResult(list);
    }

    // DOIT: 2017-01-05 发动机-发动机功率

    /**
     * 获取 发动机-发动机功率 数据
     *
     * @param vo the vo
     * @return the engine power chart data
     * @throws Exception the exception
     * @author # xujf（835264047@qq.com）
     * @date # 2017-01-05 14:10:17
     */
    @RequestMapping("/getEnginePowerChartData")
    @ResponseBody
    public Object getEnginePowerChartData(CarDataAnaVo vo) throws Exception {

        // 1、获取ty文件的1/s数据
        List<TBsTyCleanSecEntity> list = carDataAnaService.getEnginePowerChartDataItvalSec(vo);

        if (PubUtil.isEmpty(list)) {
            // 2、获取定时的1/m数据
            list = carDataAnaService.getEnginePowerChartDataItvalMin(vo);
        }

        return this.getReturnResult(list);
    }

    // DOIT: 2017-01-05 电池-电压电流图表

    @RequestMapping("/getBatteryVoltCurrChartData")
    @ResponseBody
    public Object getBatteryVoltCurrChartData(CarDataAnaVo vo) throws Exception {

        // 1、获取ty文件的1/s数据
        List<TBsTyCleanSecEntity> list = carDataAnaService.getBatteryVoltCurrChartDataItvalSec(vo);

        if (PubUtil.isEmpty(list)) {
            // 2、获取定时的1/m数据
            list = carDataAnaService.getBatteryVoltCurrChartDataItvalMin(vo);
        }

        return this.getReturnResult(list);
    }

    // DOIT: 2017-01-10 电池-续航里程分析 

    @RequestMapping("/getMileageAnalChartData")
    @ResponseBody
    public Object getMileageAnalChartData(CarDataAnaVo vo) throws Exception {

        // 1、获取ty文件的1/s数据
        List<TBsTyCleanSecEntity> list = carDataAnaService.getMileageAnalChartDataItvalSec(vo);

        if (PubUtil.isEmpty(list)) {
            // 2、获取定时的1/m数据
            list = carDataAnaService.getMileageAnalChartDataItvalMin(vo);
        }

        return this.getReturnResult(list);
    }


    // DOIT: 2017-01-05 电机-电压电流图表

    @RequestMapping("/getElecVoltCurrChartData")
    @ResponseBody
    public Object getElecVoltCurrChartData(CarDataAnaVo vo) throws Exception {

        // 1、获取ty文件的1/s数据
        List<TBsTyCleanSecEntity> list = carDataAnaService.getElecVoltCurrChartDataItvalSec(vo);

        if (PubUtil.isEmpty(list)) {
            // 2、获取定时的1/m数据
            list = carDataAnaService.getElecVoltCurrChartDataItvalMin(vo);
        }

        return this.getReturnResult(list);
    }
    
    // DOIT: 2017-01-05 电机-车速转矩图表

    @RequestMapping("/getElecSpeedTorqueChartData")
    @ResponseBody
    public Object getElecSpeedTorqueChartData(CarDataAnaVo vo) throws Exception {

        // 1、获取ty文件的1/s数据
        List<TBsTyCleanSecEntity> list = carDataAnaService.getElecSpeedTorqueChartDataItvalSec(vo);

        if (PubUtil.isEmpty(list)) {
            // 2、获取定时的1/m数据
            list = carDataAnaService.getElecSpeedTorqueChartDataItvalMin(vo);
        }

        return this.getReturnResult(list);
    }

}
